package org.digitarts.rtms.spring.collectors.jdbc;

import java.util.Arrays;

public class QueryMap
{
	protected String[]	segments		= null;
	protected String	metricName		= null;
	protected int		valueColumn		= -1;
	protected String	metricType		= null;
	protected String	defaultValue	= null;

	public QueryMap()
	{

	}

	public QueryMap(String[] segments, String metricName, int valueColumn, String metricType)
	{
		super();
		this.segments = segments;
		this.metricName = metricName;
		this.valueColumn = valueColumn;
		this.metricType = metricType;
	}

	public String[] getSegments()
	{
		return segments;
	}

	public void setSegments(String[] segments)
	{
		this.segments = segments;
	}

	public String getMetricName()
	{
		return metricName;
	}

	public void setMetricName(String metricName)
	{
		this.metricName = metricName;
	}

	public int getValueColumn()
	{
		return valueColumn;
	}

	public void setValueColumn(int valueColumn)
	{
		this.valueColumn = valueColumn;
	}

	public String getMetricType()
	{
		return metricType;
	}

	public void setMetricType(String metricType)
	{
		this.metricType = metricType;
	}

	public String getDefaultValue()
	{
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue)
	{
		this.defaultValue = defaultValue;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((metricName == null) ? 0 : metricName.hashCode());
		result = prime * result + ((metricType == null) ? 0 : metricType.hashCode());
		result = prime * result + Arrays.hashCode(segments);
		result = prime * result + valueColumn;
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final QueryMap other = (QueryMap) obj;
		if (metricName == null)
		{
			if (other.metricName != null)
				return false;
		}
		else if (!metricName.equals(other.metricName))
			return false;
		if (metricType == null)
		{
			if (other.metricType != null)
				return false;
		}
		else if (!metricType.equals(other.metricType))
			return false;
		if (!Arrays.equals(segments, other.segments))
			return false;
		if (valueColumn != other.valueColumn)
			return false;
		return true;
	}

}
